Embedded Systems

Automatic Translation of Python Instruction Behaviors into C++

Bachelor’s Thesis / Student Research Project

Abstract

The Abstract Computer Architecture Description Language (ACADL) allows for fast modeling and performance evaluation of DNN Hardware Accelerators. Currently, the functional simulation of mapped DNNs is done in Python, which allows for easy use but comes with the drawback of a slow simulation.

This student project’s goal is to automatically translate the behavior of an ACADL instruction in Python into C++ to speed up the functional simulation using the Python abstract syntax tree (AST).

Python behavior description of the ADD Instruction in add_function:

class ADD(Instruction):
    def __init__(self, id: int, rs1: str, rs2: str, rd: str):
        def add_function(architectural_state: ArchitecturalState):
            rs1 = self.read_registers[0]
            rs2 = self.read_registers[1]
            rd = self.write_registers[0]

            rs1_value = architectural_state.read_register(rs1)
            rs2_value = architectural_state.read_register(rs2)
            rd_value = rs1_value + rs2_value
            architectural_state.write_register(rd, rd_value)

            pc = architectural_state.read_register("pc0")
            architectural_state.write_register("pc0", pc + int(self.size / 8))

Translation into C++:

void add_function(std::shared_ptr<Instruction> self, std::shared_ptr<ArchitecturalState> ag) {
    auto rs1 = self->read_registers[0];
    auto rs1_value = ag->read_register(rs1);

    auto rs2 = self->read_registers[1];
    auto rs2_value = ag->read_register(rs2);

    auto rd = self->write_registers[0];
    auto rd_value = rs1_value + rs2_value;

    ag->write_register(rd, rd_value);

    uint64_t pc = ag->read_register("pc0");
    pc += 4;
    ag->write_register("pc0", pc);
}

References

Requirements

  • Python
  • C++
  • Successfully atteded the lecture “Grundlagen der Rechnerarchitektur” and/or “Parallele Rechnerarchitekturen” (optional)
  • Linux (optional)

Contact

Lübeck, Konstantin

Bringmann, Oliver